package com.hsmpay.mobile.dao.finance;


import com.hsmpay.common.dao.BaseDao;
import com.hsmpay.mobile.pojo.finance.BatchClearLog;

import java.io.Serializable;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 批量结算日志dao 接口 batchClearDao
 * @author 颜铃璋
 * 创建时间: 2013-6-3
 * 对应的pojo 是 BatchClear
 * @param <Entity>
 * @param <Query>
 */
public interface BatchClearLogDao<Entity extends Serializable,Query extends Object> extends BaseDao<Entity,Query> {
	/**
	 * 根据 文件ID和索引字段  查询日志信息
	 * @param fileId
	 * @param sort
	 * @return
	 * @throws SQLException
	 */
	public BatchClearLog searchBatchClearLog(Long fileId, Integer sort)throws SQLException;
	
	/**
	 * 根据 文件ID和索引字段  查询日志信息
	 * @param fileId
	 * @param id  可能为空
	 * @param sort 可能为空
	 * @return
	 * @throws SQLException
	 */
	public BatchClearLog searchBatchClearLogByIdFId(Long fileId, Long id, Integer sort)throws SQLException;
	
	/**
	 * 根据 文件ID和索引字段  查询日志信息
	 * @param fileId
	 * @param combineOrderId
	 * @return
	 * @throws SQLException
	 */
	public BatchClearLog searchBatchClearLog(Long fileId, Long combineOrderId)throws SQLException;
	
	/** 
	 * 根据fileID 查询结算列表
	 * @return
	 * @throws SQLException
	 */
	public List<BatchClearLog> searchBatchClearLogListByFileId(Long fileId)throws SQLException;
	
	/** 
	 * 根据fileID 查询 佣金结算日志列表
	 * @return
	 * @throws SQLException
	 */
	public List<BatchClearLog> searchBrokBCLListByFileId(Long fileId)throws SQLException;
	
	/**
	 * 根据文件ID 和 状态 查询列表
	 * @param fileId
	 * @param status
	 * @return
	 * @throws SQLException
	 */
	public List<BatchClearLog> searchBCLListByFileIdAndStatus(Long fileId, Integer status)throws SQLException;
	
	/**
	 * 获取佣金日志列表
	 * @param bcl
	 * @return
	 * @throws SQLException
	 */
	public List<BatchClearLog> getBrokerageLogs(BatchClearLog bcl) throws SQLException;
	
	/**
	 * 根据结算文件记录ID批量更新合单日志状态
	 * @param batchClearFileId
	 * @param status
	 * @param reqCode
	 * @param reqMsg
	 * @return
	 * @throws SQLException
	 */
	public int updateByBatchClearFileId(Long bclId, int status, String reqCode, String reqMsg) throws SQLException;
	

	/**
	 * 根据结算文件记录ID批量更新合单日志状态
	 * @param id
	 * @param isReturnAB
	 * @return
	 * @throws SQLException
	 */
	public int updateByBCLIdAndIsReturnAB(Long id, int isReturnAB) throws SQLException;
	
	/**
	 * 获取成功 手续费费和
	 * @param bcFileId
	 * @param status
	 * @return
	 * @throws SQLException
	 */
	public double getSuccRevenueFeeSumByFileId(Long bcFileId) throws SQLException;
	
	/**
	 * 根据 ids 查询  需要回滚 的用户
	 * @param ids
	 * @return
	 * @throws SQLException
	 */
	public List<BatchClearLog> searchRollbackUserMoneyBatchClearLogListByIds(String ids) throws SQLException;
	
	/**
	 * 根据ids 获取是否回滚过的用户
	 * @param ids
	 * @return
	 * @throws SQLException
	 */
	public int getIsReturnABCountByIds(String ids)throws SQLException;
	
	/**
	 * 根据bcId 查询错误订单且 没有 退回的订单数   即没有完成结算的订单数
	 * @param bcId
	 * @return
	 * @throws SQLException
	 */
	public int getUnfinishLogCountByBcId(Long bcId) throws SQLException;
	
	/**
	 * 根据bcId 查询错误订单数
	 * @param bcId
	 * @return
	 * @throws SQLException
	 */
	public int getErrorLogCountByBcId(Long bcId) throws SQLException;
	
	/**
	 * 根据bcId 查询错误订单 交易总额
	 * @param bcId
	 * @return
	 * @throws SQLException
	 */
	public double getErrorLogSumMoneyByBcId(Long bcId) throws SQLException;
	
	/**
	 * 修改通道
	 * @param id
	 * @param channelId
	 * @param accBankCode
	 * @param revenueFee
	 * @return
	 * @throws SQLException
	 */
	public int updateBCLChannelById(Long id, Long channelId, String accBankCode, Double revenueFee) throws SQLException;
	
	/**
	 * 根据合单ID 修改日志  
	 * @param combineOrderId
	 * @param status
	 * @param clearType 2 基本结算 3 提现  4 佣金
	 * @return
	 * @throws SQLException
	 */
	public int updateLogByCombineOrderId(Long combineOrderId, Integer status, Integer clearType)throws SQLException;
	
	/**
	 * 查询金额和笔数
	 * @param batchClearLog
	 * @return
	 * @throws SQLException
	 */
	public BatchClearLog getTransMoney(BatchClearLog batchClearLog) throws SQLException;
	
	/**
	 * 查看结算日志详情
	 * @param batchClearLog
	 * @return
	 * @throws SQLException
	 */
	public List<BatchClearLog> searchLogDetialsList(BatchClearLog batchClearLog) throws SQLException;
	
	/**
	 * 结算日志详情统计数
	 * @param batchClearLog
	 * @return
	 * @throws SQLException
	 */
	public int getLogDetailsCount(BatchClearLog batchClearLog) throws SQLException;
	
	/**
	 * 查询金额和笔数
	 * @param batchClearLog
	 * @return
	 * @throws SQLException
	 */
	public BatchClearLog getTransMoneyByIds(BatchClearLog batchClearLog) throws SQLException;

	/**
	 * 根据ids 批量删除日志
	 * @param ids
	 * @throws SQLException
	 */
	public void deleteEntityByIds(String ids)throws SQLException;

	/**
	 * 单表计算
	 * @param bcl
	 * @return
	 * @throws SQLException
	 */
	public int getEntityCount_only(BatchClearLog bcl)throws SQLException;

	/**
	 * 根据 日志ID 修改日志 sort
	 * @param id
	 * @param sort
	 * @throws SQLException
	 */
	public int updateBCLSortById(Long id, int sort)throws SQLException;
	/**
	 * 根据  批次号 查询 组数据给出金系统
	 * @param parameterMap
	 * @return
	 */
	public List<Map> selectByBatchclearId(Map<String, Object> parameterMap);

	public int updateStatusByBatchClearId(Long batchClearId, Integer status);
	
	public int countByBcFileIdByStatus(Long clearFileId, int status);

	/**
	 *  银联代付 支持的银行
	 * @param actorCode
	 * @return
	 */
	public int countBankAvailable(String code);
	
	public List<Map<String,Object>> selectNotInZxbackCodeByBcfIds(Map<String, Object> parameterMap);
	
	String selectBankNameByZxbackCode(String code);
}
